<?php

class MY_Controller extends Controller {

    var $_data = FALSE;
    var $container = "container";

    function MY_Controller() {
        parent::Controller();
        $this->load->helper('date');
        $this->load->helper('form');
        $this->load->helper('url');
        $this->_data['page_title'] = '';
        $this->load->helper('animus_helper');
        $this->load->library('pagination');
        $this->load->library('session');
        $this->load->library('form_validation');
    }

    function display_view($path) {
        $this->before_render();
        $this->_data['view_path'] = $path;
        $this->load->view($this->container, $this->_data);
    }

    function before_render() {
        
    }

}

class Animus_FrontEnd_Controller extends MY_Controller {

    function Animus_FrontEnd_Controller() {
        parent::MY_Controller();
        $this->load->model('home/annonce/Animus_home_annonce');
        $this->load->model('home/Animus_home_m');
        $this->load->model('home/user/User_m');
        $this->_data['user_id'] = $this->session->userdata('user_id');
        $header['page'] = "home/header";
        $footer['page'] = "home/footer";
        $sidebar['page'] = "home/sidebar_left";
        $this->_data['sidebar'] = $sidebar;
        $this->_data['footer'] = $footer;
        $this->_data['header'] = $header;
        $this->_data['selected_region'] = 0;
        $this->_data['set_most'] = '';
        $this->_data['login_error'] = '';
        $this->_data['validate_error'] = '';
    }

    function before_render() {
        $this->_data['card_vip'] = $this->Animus_home_m->get_card_vip();
        $this->_data['premium_annonces'] = $this->Animus_home_annonce->get_premium_annonce_sidebar();
        $max_actualite_id = $this->Animus_home_m->get_actualite_max_id()->row();
        $this->_data['actualite'] = $this->Animus_home_m->get_actualite($max_actualite_id->max_id);
        $this->_data['alaune_annonce'] = $this->Animus_home_annonce->get_alaune_annonce_header();
        if ($this->session->userdata('user_id') > 0) {
            $this->_data['user_avatar'] = $this->User_m->get_avatar_user($this->session->userdata('user_id'));
        }
        $this->_data['region'] = $this->Animus_home_m->get_region();
    }

}

class Admin_Controller extends MY_Controller {

    function Admin_Controller() {
        parent::MY_Controller();
        $header['page'] = "admin/header";
        $footer['page'] = "admin/footer";
        $sidebar['page'] = "admin/admin_sidebar";
        $this->_data['sidebar'] = $sidebar;
        $this->_data['header'] = $header;
        $this->_data['footer'] = $footer;
        $this->container = 'admin/container';
        $this->load->model('Animus_admin_m');
    }
    function before_render(){
        $this->_data['anounces_types'] = $this->Animus_admin_m->get_all_annonce_types();
    }
}